package com.hyperfix.common.config;

import com.hyperfix.common.interceptor.UserInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author JiangChunYu
 * 2024/4/15
 */
@Configuration
public class WebConfigurer implements WebMvcConfigurer {
    @Resource
    private StringRedisTemplate stringRedisTemplate;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册用户拦截器
        registry.addInterceptor(new UserInterceptor(stringRedisTemplate))
                .excludePathPatterns(
                        "/login/login_auth",
                        "/login/captcha")
                .order(1);
    }
}
